﻿using System.Collections.Generic;
using System.Xml.Linq;
using Xunit;
using YBBEST.Office365Portal.Core;

namespace YBBEST.Office365Portal.IntegrationTests
{

    public class ListsRespositoryTests
    {
        [Fact]
        public void CreateCustomListTestCreatedCustomListSuccefully()
        {
            int templateID = 100;
            IProxyConfiguration configuration = new MockProxyConfiguration();
            ListsRespository proxy = new ListsRespository(configuration,new ServiceConnection(configuration,new HttpMessageBuilder(),new MsOnlineClaimsHelper(configuration.Username,configuration.Password,configuration.SiteUrl)));
            string listName = "TestListSix";
            proxy.CreateNewList(listName, "ListDescription", templateID);
            SharePointList list = proxy.RetrieveListByName(listName);
            Assert.Equal(listName, list.Title);
            proxy.DeleteListByName(listName);
            
        }

        [Fact]
        public void RetrieveAllList()
        {
            IProxyConfiguration configuration = new MockProxyConfiguration();
            ListsRespository proxy = new ListsRespository(configuration, new ServiceConnection(configuration, new HttpMessageBuilder(), new MsOnlineClaimsHelper(configuration.Username, configuration.Password, configuration.SiteUrl)));
            IList<SharePointList> allLists = proxy.RetrieveAllLists();
            Assert.True(allLists.Count>0);
        }

        [Fact]
        public void DisplayListItems()
        {
            IProxyConfiguration configuration = new MockProxyConfiguration();
            ListsRespository proxy = new ListsRespository(configuration,new ServiceConnection(configuration,new HttpMessageBuilder(),new MsOnlineClaimsHelper(configuration.Username,configuration.Password,configuration.SiteUrl)));
            List<string> files=proxy.DisplayListItems("TestDocumentSetLib");
            Assert.Equal(files[0], "Data load transformation process.docx");
        }
    }
}
